package com.demo.database.mapper;

import com.demo.database.data.TDemoDepartment;
import com.demo.database.data.TDemoPosition;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
 * @cuthor luoxiaojiang
 * @createTime 2019年11月07日15:40:36
 * @Verson 1.0.0
 */

public interface TDemoDepartmentMapper {

    @Results(id = "departmentResultMap", value = {
            @Result(property = "departmentId", column = "department_id", id = true),
            @Result(property = "departmentName", column = "department_name"),
            @Result(property = "departmentDescribe", column = "department_describe"),
            @Result(property = "operTime", column = "oper_time")
    })
    @Select("select * from t_demo_department")
    public List<TDemoDepartment> departmentQuery() throws Exception;

    @ResultMap("departmentResultMap")
    @Select("select * from t_demo_department where department_id=#{id}")
    public TDemoDepartment departmentQueryID(Integer id) throws Exception;

    @ResultMap("departmentResultMap")
    @SelectProvider(type =DepartmentProvider.class , method = "getQueryAllSql")
    public List<TDemoDepartment> departmentQuery1(String context) throws Exception;

    @Insert("insert into t_demo_department (department_name, department_describe, oper_time) " +
            "values (#{departmentName}, #{departmentDescribe}, #{operTime})")
    public void departmentAdd(TDemoDepartment department) throws Exception;

    @Update("update t_demo_department set department_name=#{departmentName}, department_describe=#{departmentDescribe}, oper_time=#{operTime} " +
            "where department_id=#{departmentId}")
    public void departmentUpd(TDemoDepartment department) throws Exception;

    @DeleteProvider(type = DepartmentProvider.class, method = "getQueryDelSql")
    public void departmentDel(@Param("departmentIds") String... departmentIds) throws Exception;
}
